const isDev = import.meta.env.MODE === 'development'

const UUID = isDev ? 'uuid_key_dev' : 'uuid_key'
const ACCESS_TOKEN = isDev ? 'access_token_key_dev' : 'access_token_key'
const REFRESH_TOKEN = isDev ? 'refresh_token_key_dev' : 'refresh_token_key'
const USER_INFO = isDev ? 'user_info_obj_dev' : 'user_info_obj'
const HOSTORY = isDev ? 'history_key_dev' : 'history_key'
const BLOBHEX = isDev ? 'blob_hex_dev' : 'blob_hex'
const COUPON = isDev ? 'canuse_coupon_dev' : 'canuse_coupon'
const JOIN = isDev ? 'join_user_dev' : 'join_user'
const CHAT_INFO = isDev ? 'chat_info_obj_dev' : 'chat_info_obj'
const AI_CHAT_INFO = isDev ? 'ai_chat_info_obj_dev' : 'ai_chat_info_obj'
const CURRENT_MEMBER_INFO = isDev ? 'current_member_info_obj_dev' : 'current_member_info_obj'
export default {
  // 存储和用户拼团的信息
  setJoinUserData(val: any) {
    uni.setStorageSync(JOIN, val)
  },
  getJoinUserData() {
    return uni.getStorageSync(JOIN)
  },

  // 存储一个文件流
  setBlobHex(val: any) {
    uni.setStorageSync(BLOBHEX, val)
  },
  getBlobHex() {
    return uni.getStorageSync(BLOBHEX)
  },

  // 存储可使用的优惠券
  setCanUseCoupon(val: any) {
    uni.setStorageSync(COUPON, val)
  },

  getCanUseCoupon() {
    return uni.getStorageSync(COUPON)
  },

  setSearchHistory(val: any) {
    uni.setStorageSync(HOSTORY, val)
  },
  getSearchHistory() {
    return uni.getStorageSync(HOSTORY)
  },

  // 写入用户信息
  setUserInfo(val: any) {
    uni.setStorageSync(USER_INFO, val)
  },
  // 获取用户信息
  getUserInfo() {
    return uni.getStorageSync(USER_INFO)
  },

  // 写入聊天信息
  setChatInfo(val: any) {
    uni.setStorageSync(CHAT_INFO, val)
  },
  // 获取聊天信息
  getChatInfo() {
    return uni.getStorageSync(CHAT_INFO)
  },
  // 添加聊天信息
  addChatInfo(val: any) {
    let data = uni.getStorageSync(CHAT_INFO) || []
    data.push(val)
    uni.setStorageSync(CHAT_INFO, data)
  },

  // 写入AI聊天信息
  setAiChatInfo(val: any) {
    uni.setStorageSync(AI_CHAT_INFO, val)
  },
  // 获取AI聊天信息
  getAiChatInfo() {
    return uni.getStorageSync(AI_CHAT_INFO)
  },
  // 删除AI聊天信息
  removeAiChatInfo() {
    uni.removeStorageSync(AI_CHAT_INFO)
  },
  // 写入uuid
  setUuid(val: any) {
    uni.setStorageSync(UUID, val)
  },
  // 获取uuid
  getUuid() {
    return uni.getStorageSync(UUID)
  },

  // 删除uuid
  removeUuid() {
    uni.removeStorageSync(UUID)
  },
  // 写入accessToken
  setAccessToken(val: any) {
    uni.setStorageSync(ACCESS_TOKEN, val)
  },
  // 获取accessToken
  getAccessToken() {
    return uni.getStorageSync(ACCESS_TOKEN)
  },

  // 删除token
  removeAccessToken() {
    uni.removeStorageSync(ACCESS_TOKEN)
  },

  // 删除token
  removeRefreshToken() {
    uni.removeStorageSync(REFRESH_TOKEN)
  },

  setTalkToUser(val: any) {
    uni.setStorageSync('TALK_TO_USER', val)
  },
  getTalkToUser() {
    return uni.getStorageSync('TALK_TO_USER')
  },
  // 写入当前成员信息
  setCurrentMember(val: any) {
    uni.setStorageSync(CURRENT_MEMBER_INFO, val)
  },
  // 获取当前成员信息
  getCurrentMember() {
    return uni.getStorageSync(CURRENT_MEMBER_INFO)
  },
  // 删除当前成员信息
  removeCurrentMember() {
    uni.removeStorageSync(CURRENT_MEMBER_INFO)
  }
}
